refactor: Add a common codeAction method to the presentation compiler together with a supportedCodeActions method #6737
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds two methods to the presentation compiler interface so that adding new code actions will be easier.
The functions are:
public CompletableFuture<List<TextEdit>> codeAction(OffsetParams params, String codeActionId, Object codeActionPayload)
public List<CodeActionId> supportedCodeActions()
codeAction
is supposed to be a common method for executing code actions with the presentation compiler.supportedCodeActions
is a new method that is supposed to allow better handling for code actions that are implemented for only some presentation compilers e.g. only for Scala 3. (Here might be some discussion around whether we can allow some more information to be passed to this functions, so that the result will depend on e.g. the location in the file in addition to the presentation compiler used for the file).When creating a new code action that needs a new presentation compiler method that fits this interface -- only returns
List<TextEdit>
the new steps will be:CodeAction
) override itsval maybeCodeActionId: Option[String]
withSome("TheNewCodeActionIdYouCreated")
case
for your newCodeActionId
and handle the code action there.closes #6265